function updatePlayerSidebar(player) {
    var id = player.getID();

    //jQuery('#guest' + id + ' #lives').text('Lives ' + player.lives);
    if (OurGame.isMultiplayer && id != OurGame.UID) {
        jQuery('#guest' + id + ' #score').text(player.kills);
    } else {
        jQuery('#guest' + id + ' #score').text('Score ' + player.kills);
    }

    if (OurGame.isMultiplayer && id == OurGame.UID ||
        !OurGame.isMultiplayer && OurGame.players.indexOf(player) == 0) {
        $('#guest' + id + ' #bombs').empty();
        for (i = 0; i < (player.maxBombsNumber - player.currentBombsNumber); i++) {
            jQuery('<div/>', {
                class: 'bombIcon'
            }).appendTo('#guest' + id + ' #bombs');
        }
    }

    $('#guest' + id + ' #lives').empty();
    for (i = 0; i < player.lives; i++) {
        jQuery('<div/>', {
            class: 'healtIcon'
        }).appendTo('#guest' + id + ' #lives');
    }
}

function createProfileSideBar(player, myIndex) {
    var uid = OurGame.UID;
    var id = player.getID();

    jQuery('<div/>', {
        id:'guest' + id,
        class:'guest'
    }).appendTo('#upper-profile');

    jQuery('<div/>', {
        id:'guestName' + id,
        class: 'name'
    }).appendTo('#guest' + id);

    getFacebookNameById(uid, function(name) {
        jQuery("<h1/>")
            .text(name)
            .appendTo('#guestName' + id);
    });

    jQuery('<div/>', {
        id:'guestImage' + id,
        class: 'image'
    }).appendTo('#guest' + id);

    createImage(uid, '#guestImage' + id, 80);

    jQuery('<div/>', {
        id:'lives',
        class:'lives'
    }).appendTo('#guestImage' + id);

    jQuery('<div/>', {
        id:'guestInfo' + id,
        class: 'info'
    }).appendTo('#guest' + id);

    jQuery('<div/>', {
        id:'score',
        class:'score'
    }).appendTo('#guestInfo' + id);

    jQuery('<div/>', {
        id:'bombs',
        class:'bombs'
    }).appendTo('#guestInfo' + id);

    jQuery('<div/>', {
        class: 'player-color-indentifier',
        style: "width: 48px; height: 48px; background: url('img/characters/c" + (myIndex + 1) + ".png') no-repeat; background-position: 0 0;"
    }).appendTo('#guest' + id);

    updatePlayerSidebar(player);
}

function createMultiPlayerSideBar(player, myIndex) {
    var id;
    if (OurGame.isMultiplayer) {
        id = player.getID();
    } else {
        id = myIndex;
    }

    jQuery('<div/>', {
        id:'guest' + id,
        class:'multi-guest',
        style: 'float: ' + myIndex % 2 == 0 ? 'right;' : 'left;'
    }).appendTo('#lower-profiles');

    jQuery('<div/>', {
        id:'guestName' + id,
        class: 'name'
    }).appendTo('#guest' + id);

    jQuery('<img/>', {
        src:getFBSquarePictureUrlById(id),
        class:'multi-profile_pic'
    }).appendTo('#guest' + id);

    jQuery('<div/>', {
        class: 'player-color-indentifier',
        style: "float: right; width: 48px; height: 48px; background: url('img/characters/c" + (myIndex + 1) + ".png') no-repeat; background-position: 0px 0px;"
    }).appendTo('#guest' + id);

    jQuery("<div/>", {id: 'quest-name' + id}).appendTo('#guestName' + id);
    getFacebookNameById(id, function(name) {
        $('#quest-name' + id).text(name.split(/\b/)[0]);
    });

    jQuery('<div/>', {
        id:"lives"
    })
        .text('Lives ' + player.lives)
        .appendTo('#guest' + id);

    jQuery('<div/>', {
        id:"score"
    })
        .text('' + '99')
        .appendTo('#guest' + id);

    updatePlayerSidebar(player);
}

function createPlayerSideBar(player) {
    jQuery('#lower-profiles').remove();
    var id = player.getID();
    jQuery('<div/>', {
        id:'guest' + id,
        class:'guest'
    }).appendTo('#upper-profile');
    jQuery("<h1>Guest " + id + "</h1>").appendTo('#guest' + id);
    jQuery('<img/>', {
        src:"img/fb_profile_default.png",
        class:'profile_pic'
    }).appendTo('#guest' + id);
    jQuery('<div/>', {
        id:"lives"
    }).appendTo('#guest' + id);
    jQuery('#guest' + id + ' #lives').text('Lives ' + player.lives);
    jQuery('<div/>', {
        id:"score"
    }).appendTo('#guest' + id);
    jQuery('#guest' + id + ' #score').text('Score ' + player.kills);
}